import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'ifly_dialog.dart';

// ignore: non_constant_identifier_names
Future ifly_audio({
  required TextEditingController textCtrl,
}) async {
  String? result = await Get.bottomSheet(
    const IflyDialog(),
    isScrollControlled: false,
    isDismissible: false,
  );
  if (result == null) {
    return;
  }
  String str;
  int off = 0;
  if (textCtrl.text.isEmpty) {
    // textCtrl.text = result;
    str = result;
  } else {
    var _off = textCtrl.selection.baseOffset;
    off = _off;
    var _text = textCtrl.text;
    _text = _text.replaceRange(_off, _off, result);
    // textCtrl.text = _text;
    str = _text;
  }
  textCtrl.value = TextEditingValue(
      text: str,
      selection: TextSelection.fromPosition(TextPosition(
          affinity: TextAffinity.downstream, offset: off + result.length)));
}
